package cn.edu.wynu.oop.instance;

import cn.edu.wynu.oop.inherit.Student;

public class InstanceofLearn {
    public static void main(String[] args) {
        String str = "Hello World";
        if (str instanceof String) {
            System.out.println("str is an instance of String");
        } else {
            System.out.println("str is not an instance of String");
        }

        Object riley = new Student();
        if (riley instanceof String) {
            System.out.println("riley是一个字符串！");
        }

        // instanceof关键字的作用：判断一个实例（riley）是否属于某个类（Student）
        if (riley instanceof Student) {
            System.out.println("riley是一个学生！");
        }

        if (riley instanceof Object) {
            System.out.println("riley是一个Object!");
        }
    }
}
